<template>
  <div class="school">
    <h2>名称：{{ name }}</h2>
    <h2>地址：{{ address }}</h2>
    <h2>学生姓名：{{ studentName }}</h2>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: "非正常人类研究院",
      address: "火星",
      studentName: "",
    };
  },
  mounted() {
    this.$bus.$on("get-student-name", (name) => {
      this.studentName = name;
    });
  },
  beforeDestroy() {
    this.$bus.$off("get-student-name");
  },
};
</script>
<style scoped>
.school {
  background: orchid;
  margin: 3rem 0 3rem 0;
  padding: 1rem;
}
</style>
